const router = require("express").Router()
const upload = require('../utils/upload')
/* var multer  = require('multer')

var storage = multer.diskStorage({
  destination: function (req, file, cb) {
    cb(null, './public/uploads')
  },
  filename: function (req, file, cb) {
    let imgArr = file.mimetype.split('/');
    let extname = imgArr[imgArr.length-1]
    cb(null, file.fieldname + '-' + Date.now()+"."+ extname)
  }
})
 
var upload = multer({ storage: storage })
 */

router.get("/upload",(req,res)=>{
  res.render("upload")
})
router.get("/upload1",(req,res)=>{
  res.render("upload1")
})
router.post("/upload",upload.single('img'),(req,res)=>{
  res.send({
    a:10,
    b:20
  })
})

module.exports = router






/* const router = require("express").Router();

var multer  = require('multer')
var upload = multer({ dest: './public/uploads' })

router.get("/upload",(req,res)=>{
  res.render("upload")
})

router.post("/upload",upload.single('img'),(req,res)=>{
  res.send({
    a:10,
    b:20
  })
})

module.exports = router */